package com.rem.designPattern.iterator迭代器;

/**
 * @author Rem
 * @date 2022-11-23
 */
public class Client {
    public static void main(String[] args) {

        StudentAggregate studentAggregate = new StudentAggregateImpl();
        studentAggregate.addStudent(new Student("张三"));
        studentAggregate.addStudent(new Student("李四"));
        Student wangwu = new Student("王五");
        studentAggregate.addStudent(wangwu);

        studentAggregate.removeStudent(wangwu);
        StudentIterator studentIterator = studentAggregate.getStudentIterator();
        while (studentIterator.hasNext()) {
            System.out.println(studentIterator.next().getName());
        }
    }
}